﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule;
using Huirui.Cavan.Core.Extension;

namespace Huirui.Cavan.Domain.MainBoundedContext.StockModule
{
    public class StockModuleFactory
    {

        public static WareHouse CreateWareHouse(string id, string address, SystemIdentifier.WareHouseStatus status, int editUser, Corporation corporation, Department department, Employee employee)
        {
            WareHouse wareHouse = new WareHouse(id, address, status, DateTime.Now, DateTime.Now, editUser, corporation, department, employee);

            return wareHouse;
        }

        public static Stock CreateStock(string id, int nature, string name, string specification, StockType type, StockUnit stockUnit, string barCode, bool isProxy, 
            decimal standardPurchasePrice, decimal standardSalesPrice, decimal maxPurchasePrice, decimal minSalesPrice, decimal minLeftNumber, decimal taxRate, 
            int editUser, Corporation corporation, WareHouse wareHouse, StockIdentifier.StockStatus status, StockIdentifier.StockOnSale onSale, UnitTransfer unitTransfer)
        {
            Stock stock = new Stock(id, nature, name, specification, type, stockUnit, barCode, isProxy, standardPurchasePrice,
                standardSalesPrice, maxPurchasePrice, minSalesPrice, minLeftNumber, taxRate, DateTime.Now, DateTime.Now, editUser, corporation,
                wareHouse, status, onSale, unitTransfer);

            return stock;
        }

        public static StockInOutType CreateStockInOutType(string name, bool isIn, Account fromAccount, bool isCostAccounting, int editUser, Corporation corporation)
        {
            StockInOutType stockInOutType = new StockInOutType(name, isIn, fromAccount, isCostAccounting, DateTime.Now, DateTime.Now, editUser, corporation);

            return stockInOutType;
        }

        public static StockType CreateStockType(string name, int editUser)
        {
            StockType stockType = new StockType();
            stockType.Name = name;
            stockType.EditUser = editUser;
            stockType.ModifyDate = DateTime.Now;
            stockType.CreateDate = DateTime.Now;
            return stockType;
        }

        public static SupplierType CreateSupplierType(string name, int editUser)
        {
            SupplierType supplierType = new SupplierType();
            supplierType.Name = name;
            supplierType.EditUser = editUser;
            supplierType.ModifyDate = DateTime.Now;
            supplierType.CreateDate = DateTime.Now;
            return supplierType;
        }

        public static StockInOut CreateStockIn(string id, DateTime inOutDate, StockInOutType type, string sourceCode, Account fromAccount, string productionNumber, string currency, decimal currencyRate, string remark, StockIdentifier.StockInCheckedStatus checkedStatus,
            UserAccount editUser, Corporation corporation, Department department, Employee employee, Project project, Supplier supplier, Customer customer, string contact, string contactTelephone, WareHouse wareHouse)
        {
            StockInOut stockIn = new StockInOut(id, inOutDate, type, sourceCode, fromAccount, productionNumber, currency, currencyRate, remark, checkedStatus, DateTime.Now, DateTime.Now,
                editUser, corporation, department, employee, project, supplier, customer, contact, contactTelephone, wareHouse);

            return stockIn;
        }

        public static StockInOutDetail CreateStockInDetail(Account fromAccount, decimal number, decimal unitCost, StockIdentifier.CostType costType, decimal cost, decimal taxRate, decimal discountRate, string description, int editUser, Stock stock, WareHouse wareHouse)
        {
            StockInOutDetail stockIn = new StockInOutDetail(fromAccount, number, unitCost, costType, cost, taxRate, discountRate,
                description, DateTime.Now, DateTime.Now, editUser, stock, wareHouse);

            return stockIn;
        }

        public static StockAllocate CreateStockAllocate(string id, DateTime allocateDate, string remark, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation, StockInOut stockIn, StockInOut stockOut, string productionNumber)
        {
            StockAllocate stockAllocate = new StockAllocate(id, allocateDate, remark, createDate, modifyDate, editUser, corporation, stockIn, stockOut, productionNumber);

            return stockAllocate;
        }

        public static StockCheck CreateStockCheck(string id, DateTime checkDate, WareHouse wareHouse, string productionNumber, string remark, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation)
        {
            StockCheck stockCheck = new StockCheck(id, checkDate, wareHouse, productionNumber, remark, createDate, modifyDate, editUser, corporation);

            return stockCheck;
        }

        public static StockCheckDetail CreateStockCheckDetail(StockCheck stockCheck, Stock stock, decimal checkNumber, DateTime createDate, DateTime modifyDate, int editUser)
        {
            StockCheckDetail stockCheckDetail = new StockCheckDetail(stockCheck, stock, checkNumber, createDate, modifyDate, editUser);

            return stockCheckDetail;
        }

        public static UnitTransfer CreateUnitTransfer(Corporation corporation, DateTime createDate, DateTime modifyDate, int editUser, StockUnit fromUnit, StockUnit toUnit, decimal fromNumber, decimal toNumber)
        {
            UnitTransfer unitTransfer = new UnitTransfer(corporation, createDate, modifyDate, editUser, fromUnit, toUnit, fromNumber, toNumber);

            return unitTransfer;
        }

        public static StockInitialBalance CreateStockInitialBalance(Stock stock, WareHouse wareHouse, DateTime initialDate, decimal number,
            decimal unitCost, Corporation corporation, DateTime createDate, DateTime modifyDate, int editUser)
        {
            StockInitialBalance stockInitialBalance = new StockInitialBalance(initialDate, number, unitCost, corporation, stock, wareHouse, createDate, modifyDate, editUser);

            return stockInitialBalance;
        }
    }
}
